package com.example.shuiyin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shuiyin.entity.WatermarkTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @deprecated 此Mapper已被TaskMapper替代，请使用TaskMapper
 */
@Mapper
@Deprecated
public interface WatermarkTaskMapper extends BaseMapper<WatermarkTask> {
    
    @Select("SELECT * FROM tasks WHERE task_id = #{taskId}")
    WatermarkTask selectByTaskId(@Param("taskId") String taskId);
    
    @Select("SELECT * FROM tasks WHERE task_id = #{taskId} AND user_id = #{userId}")
    WatermarkTask selectByTaskIdAndUserId(@Param("taskId") String taskId, @Param("userId") Long userId);
    
    @Update("UPDATE tasks SET status = #{status}, processed_items = #{processedItems}, updated_at = NOW() WHERE task_id = #{taskId}")
    int updateTaskStatus(@Param("taskId") String taskId, @Param("status") String status, @Param("processedItems") Integer processedItems);
    
    @Select("SELECT * FROM tasks WHERE status = 'PENDING' AND type LIKE 'WATERMARK%' ORDER BY created_at ASC LIMIT #{limit}")
    List<WatermarkTask> selectPendingTasks(@Param("limit") int limit);
    
    @Select("SELECT COUNT(*) FROM tasks WHERE user_id = #{userId} AND type LIKE 'WATERMARK%' AND created_at > DATE_SUB(NOW(), INTERVAL 1 DAY)")
    int countTasksInLastDay(@Param("userId") Long userId);
} 